//
//  changePasswordController.swift
//  万才信息App
//
//  Created by 陌上互联  on 16/7/17.
//  Copyright © 2016年 万才信息. All rights reserved.
//

import UIKit

class changePasswordController: UITableViewController {
    
    @IBOutlet weak var tvOriginPass: UITextField!
    @IBOutlet weak var tvNewPwd: UITextField!
    @IBOutlet weak var tvAgainPwd: UITextField!
    
    private let waiting=waitingAlertUtil(msg: "请稍候")
    
    @IBAction func pressSubmit(sender: AnyObject) {
        
        let originPass=tvOriginPass.text!
        let newpwd=tvNewPwd.text!
        let againpwd=tvNewPwd.text!
        
        if newpwd==againpwd{
            waiting.show(self)
            basicInfo.changePassword(userUtil.getCurrUserName(), oldpwd: originPass, newpwd: newpwd, successCallback: { (data) in
                self.waiting.stop()
//                修改密码成功
                
//                退出当前页面
                self.navigationController?.popViewControllerAnimated(true)
                }, failCallback: { (error) in
                    self.waiting.stop()
                    warningAlertUtil(title: "错误", msg: error).show(self)
            })
            
            
        }else{
            warningAlertUtil(title: "填写错误", msg: "密码不一致，请重新填写").show(self)
        }
    }
    
//    ------
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    
}
